```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>微服务架构与SpringCloudAlibaba深度解析</title>
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', sans-serif;
            color: #333;
            line-height: 1.6;
            background-color: #f8fafc;
        }
        h1, h2, h3, h4, h5, h6 {
            font-family: 'Noto Serif SC', serif;
            font-weight: 600;
            color: #1a365d;
        }
        .hero {
            background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
        }
        .card {
            transition: all 0.3s ease;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }
        .card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
        }
        .feature-icon {
            font-size: 2.5rem;
            color: #3b82f6;
        }
        .highlight {
            background-color: rgba(59, 130, 246, 0.1);
            border-left: 4px solid #3b82f6;
            padding: 1rem;
            border-radius: 0 4px 4px 0;
        }
        .step-number {
            display: flex;
            align-items: center;
            justify-content: center;
            width: 2.5rem;
            height: 2.5rem;
            border-radius: 9999px;
            background-color: #3b82f6;
            color: white;
            font-weight: bold;
            margin-right: 1rem;
        }
        .timeline-item {
            position: relative;
            padding-left: 2.5rem;
            margin-bottom: 2rem;
        }
        .timeline-item:before {
            content: '';
            position: absolute;
            left: 0;
            top: 0;
            width: 2px;
            height: 100%;
            background-color: #e2e8f0;
        }
        .timeline-dot {
            position: absolute;
            left: -0.5rem;
            top: 0;
            width: 1.5rem;
            height: 1.5rem;
            border-radius: 9999px;
            background-color: #3b82f6;
            border: 4px solid #f8fafc;
        }
        .mermaid {
            background-color: white;
            padding: 1.5rem;
            border-radius: 0.5rem;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            margin: 2rem 0;
        }
        .nav-link {
            transition: all 0.2s ease;
            border-bottom: 2px solid transparent;
        }
        .nav-link:hover {
            color: #3b82f6;
            border-bottom-color: #3b82f6;
        }
        .nav-link.active {
            color: #3b82f6;
            border-bottom-color: #3b82f6;
        }
    </style>
</head>
<body class="min-h-screen">
    <!-- Hero Section -->
    <section class="hero text-white py-20 px-4 md:px-0">
        <div class="container mx-auto max-w-6xl px-4">
            <div class="flex flex-col md:flex-row items-center">
                <div class="md:w-1/2 mb-10 md:mb-0">
                    <h1 class="text-4xl md:text-5xl font-bold mb-6">微服务架构与SpringCloudAlibaba深度解析</h1>
                    <p class="text-xl mb-8 opacity-90">探索现代分布式系统架构的核心思想与最佳实践</p>
                    <div class="flex space-x-4">
                        <a href="#microservices" class="bg-white text-blue-800 px-6 py-3 rounded-lg font-semibold hover:bg-blue-50 transition">了解微服务</a>
                        <a href="#springcloud" class="border border-white px-6 py-3 rounded-lg font-semibold hover:bg-white hover:text-blue-800 transition">SpringCloudAlibaba</a>
                    </div>
                </div>
                <div class="md:w-1/2">
                    <div class="bg-white bg-opacity-20 p-8 rounded-xl backdrop-filter backdrop-blur-sm">
                        <div class="mermaid">
                            graph TD
                                A[客户端] --> B[API Gateway]
                                B --> C[服务A]
                                B --> D[服务B]
                                B --> E[服务C]
                                C --> F[数据库A]
                                D --> G[数据库B]
                                E --> H[数据库C]
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Navigation -->
    <nav class="bg-white shadow-sm sticky top-0 z-10">
        <div class="container mx-auto max-w-6xl px-4">
            <div class="flex overflow-x-auto py-4 space-x-6">
                <a href="#microservices" class="nav-link whitespace-nowrap">微服务架构思想</a>
                <a href="#springcloud" class="nav-link whitespace-nowrap">SpringCloudAlibaba</a>
                <a href="#nacos" class="nav-link whitespace-nowrap">Nacos介绍</a>
                <a href="#gateway" class="nav-link whitespace-nowrap">服务网关</a>
                <a href="#sleuth" class="nav-link whitespace-nowrap">服务日志</a>
                <a href="#cluster" class="nav-link whitespace-nowrap">Nacos集群</a>
            </div>
        </div>
    </nav>

    <!-- Main Content -->
    <main class="container mx-auto max-w-6xl px-4 py-12">
        <!-- Microservices Section -->
        <section id="microservices" class="mb-20">
            <div class="flex items-center mb-8">
                <div class="bg-blue-100 p-3 rounded-full mr-4">
                    <i class="fas fa-project-diagram feature-icon"></i>
                </div>
                <h2 class="text-3xl font-bold">1. 微服务架构思想</h2>
            </div>

            <div class="grid md:grid-cols-2 gap-8 mb-12">
                <div class="card bg-white p-6 rounded-lg">
                    <h3 class="text-xl font-semibold mb-4 flex items-center">
                        <span class="step-number">1</span>
                        微服务定义
                    </h3>
                    <p class="text-gray-700 mb-4">
                        微服务架构是一种架构模式，提倡将单一应用程序划分成一组小的服务，每个服务运行独立的进程中，服务之间互相协调配合，采用轻量级的通信机制（通常是HTTP RESTful API）。
                    </p>
                    <div class="highlight mb-4">
                        <p class="font-medium">马丁·福勒定义：</p>
                        <p>"微服务架构样式是一种将单个应用程序开发为一组小服务的方法，每个小服务都在自己的进程中运行并与轻量级机制（通常是HTTP资源API）进行通信。"</p>
                    </div>
                    <div class="flex items-center text-sm text-gray-500">
                        <i class="fas fa-link mr-2"></i>
                        <a href="https://martinfowler.com/articles/microservices.html" class="hover:text-blue-600" target="_blank">原文</a>
                        <span class="mx-2">|</span>
                        <a href="http://blog.cuicc.com/blog/2015/07/22/microservices/" class="hover:text-blue-600" target="_blank">中文翻译</a>
                    </div>
                </div>

                <div class="card bg-white p-6 rounded-lg">
                    <h3 class="text-xl font-semibold mb-4 flex items-center">
                        <span class="step-number">2</span>
                        微服务核心特性
                    </h3>
                    <ul class="space-y-3">
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span>将复杂臃肿的单体应用进行细粒度的划分</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span>每个模块单独运行在自己的容器中</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span>模块间通过HTTP、RPC、MQ等方式通信</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span>模块间无依赖关系，可独立部署</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span>可使用不同语言开发不同模块</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span>每个模块都是独立的进程</span>
                        </li>
                    </ul>
                </div>
            </div>

            <div class="mermaid">
                graph LR
                    A[单体应用] --> B[微服务架构]
                    B --> C[用户服务]
                    B --> D[订单服务]
                    B --> E[支付服务]
                    B --> F[商品服务]
                    C --> G[MySQL]
                    D --> H[MySQL]
                    E --> I[Redis]
                    F --> J[Elasticsearch]
            </div>
        </section>

        <!-- SpringCloudAlibaba Section -->
        <section id="springcloud" class="mb-20">
            <div class="flex items-center mb-8">
                <div class="bg-blue-100 p-3 rounded-full mr-4">
                    <i class="fas fa-cloud feature-icon"></i>
                </div>
                <h2 class="text-3xl font-bold">2. SpringCloudAlibaba介绍</h2>
            </div>

            <div class="card bg-white p-6 rounded-lg mb-8">
                <h3 class="text-xl font-semibold mb-4">为什么会出现SpringCloudAlibaba</h3>
                <div class="highlight mb-4">
                    <p class="font-medium">"新东西的出现必然是因为市场需求的需要"</p>
                    <p>由于Spring Cloud Netflix进入维护阶段，不再有新组件技术出现。阿里巴巴与Spring社区合作，推出SpringCloud Alibaba，既保证了技术更新，又推广了阿里云商业产品，实现双赢。</p>
                </div>
            </div>

            <div class="grid md:grid-cols-2 gap-8 mb-12">
                <div class="card bg-white p-6 rounded-lg">
                    <h3 class="text-xl font-semibold mb-4">SpringCloudAlibaba优势</h3>
                    <img src="https://cdn.nlark.com/yuque/0/2022/png/21449790/1651126049611-cc76378f-1548-4508-ba0c-eaa61f8fab11.png" alt="SpringCloudAlibaba组件" class="w-full rounded mb-4">
                    <p class="mb-4">Spring Cloud Alibaba 系列组件包含：</p>
                    <ul class="space-y-2">
                        <li><span class="font-medium">开源组件：</span>Nacos, Sentinel, RocketMQ, Dubbo, Seata, Arthas</li>
                        <li><span class="font-medium">商业组件：</span>ACM, OSS, SchedulerX</li>
                        <li><span class="font-medium">集成组件：</span>Zuul, OpenFeign, Spring Cloud Stream等</li>
                    </ul>
                </div>

                <div class="card bg-white p-6 rounded-lg">
                    <h3 class="text-xl font-semibold mb-4">主要功能</h3>
                    <ul class="space-y-3">
                        <li class="flex items-start">
                            <i class="fas fa-bolt text-yellow-500 mt-1 mr-2"></i>
                            <span><strong>服务限流降级：</strong>支持多种服务的限流降级功能，可实时修改规则</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-search text-blue-500 mt-1 mr-2"></i>
                            <span><strong>服务注册与发现：</strong>集成Ribbon支持</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-cog text-purple-500 mt-1 mr-2"></i>
                            <span><strong>分布式配置管理：</strong>支持外部化配置，配置更改自动刷新</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-envelope text-green-500 mt-1 mr-2"></i>
                            <span><strong>消息驱动能力：</strong>基于Spring Cloud Stream构建</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-exchange-alt text-red-500 mt-1 mr-2"></i>
                            <span><strong>分布式事务：</strong>使用@GlobalTransactional注解解决分布式事务问题</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-database text-indigo-500 mt-1 mr-2"></i>
                            <span><strong>阿里云对象存储：</strong>支持在任何应用、任何时间、任何地点存储和访问数据</span>
                        </li>
                    </ul>
                </div>
            </div>

            <div class="card bg-white p-6 rounded-lg">
                <h3 class="text-xl font-semibold mb-4">版本说明</h3>
                <div class="overflow-x-auto">
                    <img src="https://cdn.nlark.com/yuque/0/2022/png/21449790/1651145143182-feca13cc-7637-4a34-8fa9-6cb809ba8c83.png" alt="版本兼容性" class="w-full rounded mb-4">
                    <img src="https://cdn.nlark.com/yuque/0/2022/png/21449790/1651145168238-aa94b0f8-8fcf-46ed-aadf-3661ec5d7442.png" alt="组件版本关系" class="w-full rounded">
                </div>
            </div>
        </section>

        <!-- Nacos Section -->
        <section id="nacos" class="mb-20">
            <div class="flex items-center mb-8">
                <div class="bg-blue-100 p-3 rounded-full mr-4">
                    <i class="fas fa-server feature-icon"></i>
                </div>
                <h2 class="text-3xl font-bold">3. Nacos介绍</h2>
            </div>

            <div class="grid md:grid-cols-2 gap-8 mb-12">
                <div class="card bg-white p-6 rounded-lg">
                    <h3 class="text-xl font-semibold mb-4">什么是Nacos</h3>
                    <p class="text-gray-700 mb-4">Nacos 致力于帮助您发现、配置和管理微服务。提供动态服务发现、服务配置、服务元数据及流量管理功能。</p>
                    <a href="https://nacos.io/zh-cn/" class="text-blue-600 hover:underline flex items-center" target="_blank">
                        <i class="fas fa-external-link-alt mr-2"></i> 官方文档
                    </a>
                </div>

                <div class="card bg-white p-6 rounded-lg">
                    <h3 class="text-xl font-semibold mb-4">Nacos安装</h3>
                    <div class="timeline-item">
                        <div class="timeline-dot"></div>
                        <div>
                            <h4 class="font-medium">1. Nacos下载</h4>
                            <a href="https://github.com/alibaba/nacos/releases/tag/1.4.2" class="text-blue-600 hover:underline text-sm" target="_blank">下载地址</a>
                        </div>
                    </div>
                    <div class="timeline-item">
                        <div class="timeline-dot"></div>
                        <div>
                            <h4 class="font-medium">2. 运行Nacos</h4>
                            <p class="text-sm text-gray-600">Windows: 双击startup.cmd</p>
                            <p class="text-sm text-gray-600">Linux: <code class="bg-gray-100 px-1 rounded">./startup.sh -m standalone</code></p>
                        </div>
                    </div>
                    <div class="timeline-item">
                        <div class="timeline-dot"></div>
                        <div>
                            <h4 class="font-medium">3. 访问Nacos</h4>
                            <p class="text-sm text-gray-600">访问 <a href="http://localhost:8848/nacos" class="text-blue-600 hover:underline" target="_blank">http://localhost:8848/nacos</a></p>
                            <p class="text-sm text-gray-600">默认用户名/密码: nacos/nacos</p>
                        </div>
                    </div>
                </div>
            </div>

            <div class="grid md:grid-cols-2 gap-8">
                <div class="card bg-white p-6 rounded-lg">
                    <h3 class="text-xl font-semibold mb-4">Nacos服务注册</h3>
                    <p class="mb-4">Nacos作为服务注册中心替代Eureka，服务实例在启动时注册到服务注册表，关闭时注销。</p>
                    
                    <h4 class="font-medium mb-2">服务注册示例代码</h4>
                    <div class="bg-gray-800 text-gray-100 p-4 rounded mb-4 overflow-x-auto">
                        <pre><code class="text-sm">
// pom.xml
&lt;dependency&gt;
    &lt;groupId&gt;com.alibaba.cloud&lt;/groupId&gt;
    &lt;artifactId&gt;spring-cloud-starter-alibaba-nacos-discovery&lt;/artifactId&gt;
&lt;/dependency&gt;

// application.yml
spring:
  cloud:
    nacos:
      discovery:
        server-addr: 127.0.0.1:8848

// 主启动类
@SpringBootApplication
@EnableDiscoveryClient
public class Application {
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}
                        </code></pre>
                    </div>
                </div>

                <div class="card bg-white p-6 rounded-lg">
                    <h3 class="text-xl font-semibold mb-4">Nacos服务发现</h3>
                    <p class="mb-4">Nacos提供客户端负载均衡功能，可以从Nacos Server拉取服务信息。</p>
                    
                    <h4 class="font-medium mb-2">客户端负载均衡示例</h4>
                    <div class="bg-gray-800 text-gray-100 p-4 rounded mb-4 overflow-x-auto">
                        <pre><code class="text-sm">
// Ribbon方式
@Bean
@LoadBalanced
public RestTemplate restTemplate() {
    return new RestTemplate();
}

@GetMapping("/server2")
public String server2() {
    return restTemplate.getForObject(
        "http://server1/server1", String.class);
}

// Nacos Discovery方式
@Autowired
private NacosDiscoveryClient nacosDiscoveryClient;

public void test() {
    List&lt;ServiceInstance&gt; instances = 
        nacosDiscoveryClient.getInstances("server1");
    // 随机选择实例
    ServiceInstance instance = instances.get(
        new Random().nextInt(instances.size()));
}
                        </code></pre>
                    </div>
                </div>
            </div>

            <div class="mt-12">
                <h3 class="text-xl font-semibold mb-4">Nacos配置中心</h3>
                <div class="grid md:grid-cols-2 gap-8">
                    <div class="card bg-white p-6 rounded-lg">
                        <h4 class="font-medium mb-2">配置中心使用</h4>
                        <p class="mb-4">Nacos可以作为配置中心，支持动态配置刷新。</p>
                        <div class="bg-gray-800 text-gray-100 p-4 rounded mb-4 overflow-x-auto">
                            <pre><code class="text-sm">
// bootstrap.yml
spring:
  cloud:
    nacos:
      config:
        server-addr: localhost:8848
        file-extension: yaml
  application:
    name: server-config
  profiles:
    active: dev

// Controller
@RestController
@RefreshScope
public class ConfigController {
    @Value("${config.test}")
    private String test;
    
    @GetMapping("/hello")
    public String hello() {
        return test;
    }
}
                            </code></pre>
                        </div>
                    </div>
                    <div class="card bg-white p-6 rounded-lg">
                        <h4 class="font-medium mb-2">多环境配置</h4>
                        <p class="mb-2">Nacos支持多环境配置管理：</p>
                        <ul class="space-y-2 mb-4">
                            <li><strong>命名空间(Namespace):</strong> 用于环境隔离(dev/test/prod)</li>
                            <li><strong>分组(Group):</strong> 同一环境不同服务分组</li>
                            <li><strong>Data ID:</strong> 具体配置文件</li>
                        </ul>
                        <div class="bg-gray-800 text-gray-100 p-4 rounded overflow-x-auto">
                            <pre><code class="text-sm">
// 多环境配置示例
spring:
  cloud:
    nacos:
      config:
        server-addr: localhost:8848
        file-extension: yaml
        group: INFO_GROUP
        namespace: 059b8812-2a6e-4633-a19f-3165a8472b79
                            </code></pre>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Gateway Section -->
        <section id="gateway" class="mb-20">
            <div class="flex items-center mb-8">
                <div class="bg-blue-100 p-3 rounded-full mr-4">
                    <i class="fas fa-door-open feature-icon"></i>
                </div>
                <h2 class="text-3xl font-bold">4. 服务网关-Gateway</h2>
            </div>

            <div class="card bg-white p-6 rounded-lg mb-8">
                <h3 class="text-xl font-semibold mb-4">Gateway核心组件</h3>
                <div class="grid md:grid-cols-3 gap-6">
                    <div>
                        <div class="bg-blue-50 p-4 rounded-lg">
                            <h4 class="font-bold text-blue-800 mb-2">Route（路由）</h4>
                            <p class="text-sm">路由的基本单元，由ID、URI、一组Predicate、一组Filter组成</p>
                        </div>
                    </div>
                    <div>
                        <div class="bg-green-50 p-4 rounded-lg">
                            <h4 class="font-bold text-green-800 mb-2">Predicate（断言）</h4>
                            <p class="text-sm">路由转发的判断条件，支持Path、Query、Method、Header等</p>
                        </div>
                    </div>
                    <div>
                        <div class="bg-purple-50 p-4 rounded-lg">
                            <h4 class="font-bold text-purple-800 mb-2">Filter（过滤器）</h4>
                            <p class="text-sm">路由转发时经过的过滤逻辑，可修改请求、响应内容</p>
                        </div>
                    </div>
                </div>
            </div>

            <div class="grid md:grid-cols-2 gap-8 mb-12">
                <div class="card bg-white p-6 rounded-lg">
                    <h3 class="text-xl font-semibold mb-4">Gateway环境搭建</h3>
                    <div class="bg-gray-800 text-gray-100 p-4 rounded mb-4 overflow-x-auto">
                        <pre><code class="text-sm">
// pom.xml
&lt;dependency&gt;
    &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
    &lt;artifactId&gt;spring-cloud-starter-gateway&lt;/artifactId&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
    &lt;groupId&gt;com.alibaba.cloud&lt;/groupId&gt;
    &lt;artifactId&gt;spring-cloud-starter-alibaba-nacos-discovery&lt;/artifactId&gt;
&lt;/dependency&gt;

// application.yml
server:
  port: 88
spring:
  cloud:
    gateway:
      routes:
        - id: provider
          uri: lb://01-provider
          predicates:
            - Path=/provider/**
          filters:
            - StripPrefix=1
                        </code></pre>
                    </div>
                </div>

                <div class="card bg-white p-6 rounded-lg">
                    <h3 class="text-xl font-semibold mb-4">常用Predicate</h3>
                    <ul class="space-y-3">
                        <li>
                            <span class="font-medium">Path:</span> 路径匹配
                            <code class="bg-gray-100 px-1 rounded text-sm">Path=/api/**</code>
                        </li>
                        <li>
                            <span class="font-medium">After:</span> 指定时间后匹配
                            <code class="bg-gray-100 px-1 rounded text-sm">After=2021-08-08T17:36:20.014+08:00</code>
                        </li>
                        <li>
                            <span class="font-medium">Header:</span> 请求头匹配
                            <code class="bg-gray-100 px-1 rounded text-sm">Header=X-Request-Id, \d+</code>
                        </li>
                        <li>
                            <span class="font-medium">Cookie:</span> Cookie匹配
                            <code class="bg-gray-100 px-1 rounded text-sm">Cookie=sessionId, test</code>
                        </li>
                        <li>
                            <span class="font-medium">Weight:</span> 权重路由
                            <code class="bg-gray-100 px-1 rounded text-sm">Weight=group1, 80</code>
                        </li>
                    </ul>
                </div>
            </div>

            <div class="card bg-white p-6 rounded-lg">
                <h3 class="text-xl font-semibold mb-4">自定义全局Filter</h3>
                <div class="bg-gray-800 text-gray-100 p-4 rounded overflow-x-auto">
                    <pre><code class="text-sm">
@Component
public class GatewayFilter implements GlobalFilter, Ordered {
    @Override
    public Mono&lt;Void&gt; filter(ServerWebExchange exchange, 
                            GatewayFilterChain chain) {
        // 获取请求参数
        String age = exchange.getRequest()
                           .getQueryParams()
                           .getFirst("age");
        
        // 业务逻辑判断
        if("20".equals(age)){
            return chain.filter(exchange); // 放行
        }
        
        // 错误处理
        ServerHttpResponse response = exchange.getResponse();
        response.setStatusCode(HttpStatus.INTERNAL_SERVER_ERROR);
        return response.setComplete();
    }

    @Override
    public int getOrder() {
        return -1; // 优先级
    }
}
                    </code></pre>
                </div>
            </div>
        </section>

        <!-- Sleuth Section -->
        <section id="sleuth" class="mb-20">
            <div class="flex items-center mb-8">
                <div class="bg-blue-100 p-3 rounded-full mr-4">
                    <i class="fas fa-search feature-icon"></i>
                </div>
                <h2 class="text-3xl font-bold">5. 服务日志</h2>
            </div>

            <div class="grid md:grid-cols-2 gap-8">
                <div class="card bg-white p-6 rounded-lg">
                    <h3 class="text-xl font-semibold mb-4">Sleuth使用</h3>
                    <p class="mb-4">Sleuth可以获取整个服务链路的信息，通过Trace ID和Span ID追踪请求链路。</p>
                    <div class="bg-gray-800 text-gray-100 p-4 rounded mb-4 overflow-x-auto">
                        <pre><code class="text-sm">
// pom.xml
&lt;dependency&gt;
    &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
    &lt;artifactId&gt;spring-cloud-starter-sleuth&lt;/artifactId&gt;
&lt;/dependency&gt;

// 控制台输出示例
[SEARCH,96f95a0dd81fe3ab,852ef4cfddec901f,false]
// SEARCH: 服务名称
// 96f95a0dd81fe3ab: Trace ID(整个请求链路唯一)
// 852ef4cfddec901f: Span ID(基本工作单元)
// false: 是否将信息输出到其他系统
                        </code></pre>
                    </div>
                </div>

                <div class="card bg-white p-6 rounded-lg">
                    <h3 class="text-xl font-semibold mb-4">Sleuth整合Zipkin</h3>
                    <p class="mb-4">Zipkin通过图形化界面展示服务链路信息，便于问题排查。</p>
                    <div class="bg-gray-800 text-gray-100 p-4 rounded mb-4 overflow-x-auto">
                        <pre><code class="text-sm">
// docker-compose.yml
version: "3.1"
services:
  zipkin:
    image: openzipkin/zipkin
    ports:
      - 9411:9411

// application.yml
spring:
  sleuth:
    sampler:
      probability: 1.0 # 采样率
  zipkin:
    base-url: http://localhost:9411/
                        </code></pre>
                    </div>
                    <img src="https://cdn.nlark.com/yuque/0/2022/png/21449790/1651149310637-bef5dd9d-6eb6-4dc5-aa36-7805bb771e12.png" alt="Zipkin界面" class="w-full rounded">
                </div>
            </div>
        </section>

        <!-- Nacos Cluster Section -->
        <section id="cluster">
            <div class="flex items-center mb-8">
                <div class="bg-blue-100 p-3 rounded-full mr-4">
                    <i class="fas fa-network-wired feature-icon"></i>
                </div>
                <h2 class="text-3xl font-bold">6. Nacos集群</h2>
            </div>

            <div class="card bg-white p-6 rounded-lg mb-8">
                <h3 class="text-xl font-semibold mb-4">Nacos集群模式</h3>
                <div class="grid md:grid-cols-3 gap-6">
                    <div class="bg-blue-50 p-4 rounded-lg">
                        <h4 class="font-bold text-blue-800 mb-2">单机模式</h4>
                        <p class="text-sm">用于测试和单机试用</p>
                    </div>
                    <div class="bg-green-50 p-4 rounded-lg">
                        <h4 class="font-bold text-green-800 mb-2">集群模式</h4>
                        <p class="text-sm">用于生产环境，确保高可用</p>
                    </div>
                    <div class="bg-purple-50 p-4 rounded-lg">
                        <h4 class="font-bold text-purple-800 mb-2">多集群模式</h4>
                        <p class="text-sm">用于多数据中心场景</p>
                    </div>
                </div>
            </div>

            <div class="grid md:grid-cols-2 gap-8 mb-12">
                <div class="card bg-white p-6 rounded-lg">
                    <h3 class="text-xl font-semibold mb-4">Nacos集群搭建步骤</h3>
                    <div class="timeline-item">
                        <div class="timeline-dot"></div>
                        <div>
                            <h4 class="font-medium">1. 设置持久化到MySQL</h4>
                            <p class="text-sm text-gray-600">修改conf/application.properties配置数据库连接</p>
                        </div>
                    </div>
                    <div class="timeline-item">
                        <div class="timeline-dot"></div>
                        <div>
                            <h4 class="font-medium">2. 配置集群节点</h4>
                            <p class="text-sm text-gray-600">修改conf/cluster.conf添加集群节点IP和端口</p>
                        </div>
                    </div>
                    <div class="timeline-item">
                        <div class="timeline-dot"></div>
                        <div>
                            <h4 class="font-medium">3. 启动集群</h4>
                            <p class="text-sm text-gray-600">分别启动每个Nacos节点</p>
                        </div>
                    </div>
                    <div class="timeline-item">
                        <div class="timeline-dot"></div>
                        <div>
                            <h4 class="font-medium">4. Nginx反向代理</h4>
                            <p class="text-sm text-gray-600">配置Nginx实现负载均衡</p>
                        </div>
                    </div>
                </div>

                <div class="card bg-white p-6 rounded-lg">
                    <h3 class="text-xl font-semibold mb-4">Nginx配置示例</h3>
                    <div class="bg-gray-800 text-gray-100 p-4 rounded overflow-x-auto">
                        <pre><code class="text-sm">
upstream nacoscluster {
    server 192.168.147.200:8001;
    server 192.168.147.200:8002;
    server 192.168.147.200:8003;
}

server {
    listen 8080;
    server_name localhost;
    location / {
        proxy_pass http://nacoscluster;
    }
}
                        </code></pre>
                    </div>
                    <p class="mt-4 text-sm">客户端通过Nginx访问Nacos集群：</p>
                    <div class="bg-gray-800 text-gray-100 p-4 rounded mt-2 overflow-x-auto">
                        <pre><code class="text-sm">
spring:
  cloud:
    nacos:
      discovery:
        server-addr: 192.168.147.200:8080
                        </code></pre>
                    </div>
                </div>
            </div>

            <div class="card bg-white p-6 rounded-lg">
                <h3 class="text-xl font-semibold mb-4">Nacos集群原理</h3>
                <p class="mb-4">Nacos集群采用raft算法实现选举和数据同步：</p>
                <div class="mermaid">
                    graph TD
                        A[客户端] --> B[Leader]
                        B --> C[Follower]
                        B --> D[Follower]
                        C --> B
                        D --> B
                </div>
                <div class="mt-4 grid md:grid-cols-3 gap-4">
                    <div class="bg-blue-50 p-4 rounded-lg">
                        <h4 class="font-bold text-blue-800 mb-2">Leader</h4>
                        <p class="text-sm">负责接收客户端的请求</p>
                    </div>
                    <div class="bg-green-50 p-4 rounded-lg">
                        <h4 class="font-bold text-green-800 mb-2">Candidate</h4>
                        <p class="text-sm">用于选举Leader的角色</p>
                    </div>
                    <div class="bg-purple-50 p-4 rounded-lg">
                        <h4 class="font-bold text-purple-800 mb-2">Follower</h4>
                        <p class="text-sm">负责响应Leader或Candidate的请求</p>
                    </div>
                </div>
            </div>
        </section>
    </main>

    <script>
        // 初始化Mermaid
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: false,
                htmlLabels: true,
                curve: 'basis'
            }
        });

        // 导航栏高亮
        const sections = document.querySelectorAll('section');
        const navLinks = document.querySelectorAll('.nav-link');

        window.addEventListener('scroll', () => {
            let current = '';
            
            sections.forEach(section => {
                const sectionTop = section.offsetTop;
                const sectionHeight = section.clientHeight;
                
                if (pageYOffset >= (sectionTop - 300)) {
                    current = section.getAttribute('id');
                }
            });
            
            navLinks.forEach(link => {
                link.classList.remove('active');
                if (link.getAttribute('href') === `#${current}`) {
                    link.classList.add('active');
                }
            });
        });
    </script>
</body>
</html>
```